//
//  Child.m
//  NotificationDemo
//
//  Created by shk on 14/12/10.
//  Copyright (c) 2014年 com.shk. All rights reserved.
//

#import "Child.h"

@implementation Child

-(id)initChildSleep{
    self = [super init];
    if(self != nil){
        _sleepTime = 100;
        [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeAction:) userInfo:nil repeats:YES];
    }
    return self;
}

-(void) timeAction:(NSTimer *) timer{
    _sleepTime-=2;
    if(_sleepTime < 90){
        NSDictionary *dic = @{@"sleepTime":[NSNumber numberWithInteger:_sleepTime]};//也可以传字典（多值）类型的数据
        [[NSNotificationCenter defaultCenter] postNotificationName:CHILD_WEAK_NOTIFICATION object:[NSNumber numberWithInteger:_sleepTime] userInfo:dic];//发出小孩醒来的通知
        [timer invalidate];//关闭定时器
    }else{
        NSLog(@"小孩睡眠中...");
    }
}


@end
